

#include <gfx/texturepack.h>
#include <gfx/idevice.h>
#include <gfx/itexture.h>


ceTexturePack::ceTexturePack()
{
  CE_OBJECT_CONSTR
	for (unsigned r=0; r<RP_Count; r++)
		{
			for (unsigned i=0; i<TS_Count; i++)
				{
					_textures[r][i] = 0;
				}
		}
}

ceTexturePack::~ceTexturePack()
{
  for (unsigned r=0; r<RP_Count; r++)
    {
      for (unsigned i=0; i<TS_Count; i++)
        {
          iTexture* txt = _textures[r][i];
          CE_UNSET(txt);
        }
    }

}

void ceTexturePack::SetTexture(ceRenderPass rp, ceTextureStage stage, iTexture *texture)
{
  _textures[rp][stage] = texture;
}


const iTexture* ceTexturePack::GetTexture(ceRenderPass rp, ceTextureStage stage) const
{
  return _textures[rp][stage];
}

iTexture* ceTexturePack::GetTexture(ceRenderPass rp, ceTextureStage stage)
{
  return _textures[rp][stage];
}

void ceTexturePack::Bind(ceRenderPass rp, iDevice *device)
{
  for (unsigned i=0; i<TS_Count; i++)
    {
      device->SetTexture((ceTextureStage)i, _textures[rp][i]);
    }
}
